#include "stdafx.h"
#include "EXResMng.h"


CEXResMng::CEXResMng(void)
{
  EmptyResource();
  InitResourceMng();
}


CEXResMng::~CEXResMng(void)
{
  EmptyResource();
}

void CEXResMng::EmptyResource()
{  
  EmptyResourceResSet();
  EmptyResourceColor();
  EmptyResourceFont();
  EmptyResourceColorSet();
  EmptyResourceImg();
}

void CEXResMng::EmptyResourceImg()
{
  INT_PTR iCnt = m_arrResImg.GetSize();
  for(iCnt-- ; iCnt >= 0 ; iCnt--)
  {
    delete m_arrResImg.GetAt( iCnt );
    m_arrResImg.RemoveAt( iCnt );
  }
}
void CEXResMng::InitImg()
{
  RegistImg(IMG_PUSHBTN_BG, IDB_BITMAP5, 4);
  RegistImg(IMG_CHECKBTN_CHECK, IDB_BTN_CHECKBOX, 4);
  RegistImg(IMG_CHECKBTN_UNCHECK, IDB_BTN_UNCHECKBOX, 4);
  RegistImg(IMG_RADIOBTN_CLICK, IDB_BTN_CHECKRADIO, 4);
  RegistImg(IMG_RADIOBTN_UNCLICK, IDB_BTN_UNCHECKRADIO, 4);

  RegistImg(IMG_STATIC_BG, IDB_STATIC_BG, 1);
  
  RegistImg(IMG_EDIT_BG, IDB_STATIC_BG, 1);
  RegistImg(IMG_EDIT_SPIN_BG, IDB_SPIN_TEXTBOX, 4);
  
  RegistImg(IMG_HEADER_BG, IDB_HEADER_BG_SS, 1);

  RegistImg(IMG_HSCROLL_LEFT, IDB_HSCROLL_LEFT, 4);
  RegistImg(IMG_HSCROLL_RIGHT, IDB_HSCROLL_RIGHT, 4);
  RegistImg(IMG_HSCROLL_BG, IDB_HSCROLL_BG_S, 4);
  RegistImg(IMG_HSCROLL_THUMB, IDB_HSCROLL_THUMB, 4);
  RegistImg(IMG_HSCROLL_THUMB_BG, IDB_HSCROLL_BG, 1);
  RegistImg(IMG_HSCROLL_THUMB_ARROW, IDB_HSCROLL_THUMB_ARROW, 4);

  RegistImg(IMG_VSCROLL_LEFT, IDB_VSCROLL_UP, 4);
  RegistImg(IMG_VSCROLL_RIGHT, IDB_VSCROLL_DOWN, 4);
  RegistImg(IMG_VSCROLL_BG, IDB_VSCROLL_BG_S, 4);
  RegistImg(IMG_VSCROLL_THUMB, IDB_VSCROLL_THUMB, 4);
  RegistImg(IMG_VSCROLL_THUMB_BG, IDB_VSCROLL_BG, 1);
  RegistImg(IMG_VSCROLL_THUMB_ARROW, IDB_VSCROLL_THUMB_ARROW, 4);

  RegistImg(IMG_PROGRESS_BG, IDB_STATIC_BG, 1);
  RegistImg(IMG_PROGRESS_BAR, IDB_PG_PROGRESS, 4);

  RegistImg(IMG_SLIDER_CHANNEL_H, IDB_SLIDER_CHANNEL_H, 1);
  RegistImg(IMG_SLIDER_THUMB_H, IDB_SLIDER_THUMB_H, 4);

  RegistImg(IMG_SPIN_VERT_BG, IDB_SPIN_VERT_BG, 4);
  RegistImg(IMG_SPIN_VERT_DOWN, IDB_SPIN_VERT_DOWN, 4);
  RegistImg(IMG_SPIN_VERT_UP, IDB_SPIN_VERT_UP, 4);
 
  RegistImg(IMG_COMBO_BG, IDB_COMBO_BG, 4);
  RegistImg(IMG_COMBO_BTN, IDB_COMBO_BTN, 4);
  RegistImg(IMG_EDIT_COMBO_BG, IDB_COMBO_EDIT, 4);

  RegistImg(IMG_TEXTBOX_BG, IDB_TEXTBOX_D, 4);
  RegistImg(IMG_IP_TEXTBOX_BG, IDB_IP_TEXTBOX_B, 4);

  RegistImg(IMG_DIALOG_TOP, IDB_DLG_TOP, 1);
  RegistImg(IMG_DIALOG_BOTTOM, IDB_DLG_BOTTOM, 1);
  RegistImg(IMG_DIALOG_LEFT, IDB_DLG_LEFT, 1);
  RegistImg(IMG_DIALOG_RIGHT, IDB_DLG_RIGHT, 1);
  RegistImg(IMG_DIALOG_LEFT_TOP, IDB_DLG_LEFT_TOP, 1);
  RegistImg(IMG_DIALOG_LEFT_BOTTOM, IDB_DLG_LEFT_BOTTOM, 1);
  RegistImg(IMG_DIALOG_RIGHT_TOP, IDB_DLG_RIGHT_TOP, 1);
  RegistImg(IMG_DIALOG_RIGHT_BOTTOM, IDB_DLG_RIGHT_BOTTOM, 1);
  
  RegistImg(IMG_MSGBOX_BG, IDB_DLG_BUTTON, 4);
}

INT_PTR CEXResMng::FindImgIndex(UINT nID)
{
  INT_PTR iCnt = m_arrResImg.GetSize();
  for( iCnt--; iCnt >= 0; iCnt-- )
    if( m_arrResImg.GetAt( iCnt )->m_nID == nID )
      break;
  return iCnt;
}

int CEXResMng::RegistImg(UINT nId, UINT nImgid, int ndivide_Count)
{
  if(FindImgIndex(nId) >= 0)
    return -1;

  RESOURCE_IMAGE * pImg = new RESOURCE_IMAGE;
  pImg->m_nID = nId;
  pImg->m_nImgId = nImgid;
  pImg->m_nImgCnt = ndivide_Count;

  m_arrResImg.Add( pImg );
  return 1;
}

UINT CEXResMng::GetImg(UINT nId)
{
  INT_PTR iIndex = FindImgIndex(nId);

  return m_arrResImg.GetAt(iIndex)->m_nImgId;
}
int CEXResMng::GetImgCount(UINT nId)
{
  INT_PTR iIndex = FindImgIndex( nId );

  return m_arrResImg.GetAt( iIndex )->m_nImgCnt;
}
void CEXResMng::EmptyResourceResSet()
{
  INT_PTR iCount = m_arrResSet.GetSize();
  for( iCount--; iCount >= 0; iCount-- )
  {
    delete m_arrResSet.GetAt( iCount );
    m_arrResSet.RemoveAt( iCount );
  }
}

void CEXResMng::EmptyResourceColorSet()
{
  INT_PTR iCount = m_arrResourceColorSet.GetSize();
  for( iCount--; iCount >= 0; iCount-- )
  {
    delete m_arrResourceColorSet.GetAt( iCount );
    m_arrResourceColorSet.RemoveAt( iCount );
  }
}

void CEXResMng::EmptyResourceColor()
{
  INT_PTR iCount = m_arrResourceColor.GetSize();
  for( iCount--; iCount >= 0; iCount-- )
  {
    delete m_arrResourceColor.GetAt( iCount );
    m_arrResourceColor.RemoveAt( iCount );
  }
}

void CEXResMng::EmptyResourceFont()
{
  INT_PTR iCount = m_arrResourceFont.GetSize();
  for( iCount--; iCount >= 0; iCount-- )
  {
    delete m_arrResourceFont.GetAt( iCount );
    m_arrResourceFont.RemoveAt( iCount );
  }
}

int CEXResMng::InitResourceMng()
{
  InitColor();
  InitColorSet();
  InitFont();
  InitImg();
  InitResSet();

  return 1;
}

void CEXResMng::InitColor()
{
  RegistColor(COLOR_DARK, RGB(30, 30, 30));
  RegistColor(COLOR_BASIC, RGB(184, 188, 209));
  RegistColor(COLOR_BRIGHTNESS, RGB(180, 180, 180));
  RegistColor(COLOR_MAGENTA, RGB(255, 0, 255));
  RegistColor(COLOR_DARK_DIALOG, RGB(174, 175, 193));
}

int CEXResMng::RegistColor(UINT nId, COLORREF crColor)
{
  if( FindColorIndex( nId ) >= 0 )
    return -1;

  RESOURCE_COLOR * pColor = new RESOURCE_COLOR;
  pColor->m_nID = nId;
  pColor->m_crBkColor = crColor;
  
  m_arrResourceColor.Add( pColor );
  return 1;
}

INT_PTR CEXResMng::FindColorIndex(UINT nID)
{
  INT_PTR iCount = m_arrResourceColor.GetSize();
  for( iCount--; iCount >= 0; iCount-- )
    if( m_arrResourceColor.GetAt( iCount )->m_nID == nID )
      break;

  return iCount;
}

COLORREF CEXResMng::GetColor(UINT nId)
{
  INT_PTR iIndex = FindColorIndex( nId );
  if( iIndex == -1 )
  {
    return RGB(0, 0, 0);
  }

  return m_arrResourceColor.GetAt( iIndex )->m_crBkColor;
}


void CEXResMng::InitColorSet()
{
  RegistColorSet(COLORSET_DARK, RGB(30,30,30), RGB(50, 50, 50), 
    RGB(100, 100, 100), RGB(150, 150, 150));
  RegistColorSet(COLORSET_BASIC, RGB(40,40,40), RGB(100, 100, 100), 
    RGB(150, 150, 150), RGB(200, 200, 200));
  RegistColorSet(COLORSET_BRIGHTNESS, RGB(50,50,50), RGB(150, 150, 150), 
    RGB(200, 200, 200), RGB(222, 222, 222));
}

void CEXResMng::InitFont()
{
  LOGFONT lf = {0};
  lf.lfWidth=0;
  lf.lfEscapement=0;
  lf.lfOrientation=0;
  lf.lfWeight=FW_NORMAL;
  lf.lfItalic=0;
  lf.lfUnderline=0;
  lf.lfStrikeOut=0;
  lf.lfCharSet=DEFAULT_CHARSET; //ANSI_CHARSET;
  lf.lfOutPrecision=OUT_DEFAULT_PRECIS;
  lf.lfClipPrecision=CLIP_DEFAULT_PRECIS;
  lf.lfQuality=PROOF_QUALITY;
  lf.lfPitchAndFamily=VARIABLE_PITCH | FF_ROMAN;
  lstrcpy(lf.lfFaceName, L"Times New Roman");
  
  lf.lfHeight=-12;
  RegistFont(FONT_DARK_SMALL, RGB(50,50,50), lf);
  RegistFont(FONT_BASIC_SMALL, RGB(122,122,122), lf);
  RegistFont(FONT_BRIGHTNESS_SMALL, RGB(200,200,200), lf);

  lf.lfHeight=-15;
  RegistFont(FONT_DARK_NORMAL, RGB(50,50,50), lf);
  RegistFont(FONT_BASIC_NORMAL, RGB(122,122,122), lf);
  RegistFont(FONT_BRIGHTNESS_NORMAL, RGB(0,255,0), lf);
  
  lf.lfHeight=-20;
  RegistFont(FONT_DARK_LARGE, RGB(50,50,50), lf);
  RegistFont(FONT_BASIC_LARGE, RGB(122,122,122), lf);
  RegistFont(FONT_BRIGHTNESS_LARGE, RGB(0,255,0), lf);

}

int CEXResMng::RegistFont(UINT nId, COLORREF crtext, LOGFONT log_font)
{
  RESOURCE_FONT * pFont = new RESOURCE_FONT;
  pFont->m_nID = nId;
  pFont->m_Font.CreateFontIndirect(&log_font);
  pFont->m_crText = crtext;

  m_arrResourceFont.Add(pFont);

  return 1;
}

int CEXResMng::RegistColorSet(UINT nId, COLORREF crNormal/* = 0*/, 
                            COLORREF crSelect/* = 0*/, COLORREF crFocus/* = 0*/, 
                            COLORREF crDisable/* = 0*/)
{
  if( FindColorSetIndex( nId ) >= 0 )
    return -1;

  RESOURCE_COLORSET * pColorSet = new RESOURCE_COLORSET;
  pColorSet->m_nID = nId;
  pColorSet->m_crStateColor[0] = crNormal;
  pColorSet->m_crStateColor[1] = crSelect;
  pColorSet->m_crStateColor[2] = crFocus;
  pColorSet->m_crStateColor[3] = crDisable;
  
  m_arrResourceColorSet.Add( pColorSet );
  return 1;
}

INT_PTR CEXResMng::FindColorSetIndex(UINT nID)
{
  INT_PTR iCount = m_arrResourceColorSet.GetSize();
  for( iCount--; iCount >= 0; iCount-- )
    if( m_arrResourceColorSet.GetAt( iCount )->m_nID == nID )
      break;

  return iCount;
}

COLORREF* CEXResMng::GetColorSet(UINT nId)
{
  INT_PTR iIndex = FindColorSetIndex( nId );

  return m_arrResourceColorSet.GetAt( iIndex )->m_crStateColor;
}

CFont* CEXResMng::GetFont(UINT nId)
{
  INT_PTR iIndex = FindFontIndex( nId );

  return CFont::FromHandle(m_arrResourceFont.GetAt( iIndex )->m_Font);
}

COLORREF CEXResMng::GetFontColor(UINT nId)
{
  INT_PTR iIndex = FindFontIndex( nId );

  return m_arrResourceFont.GetAt( iIndex )->m_crText;
}

INT_PTR CEXResMng::FindFontIndex(UINT nID)
{
  INT_PTR iCount = m_arrResourceFont.GetSize();
  for( iCount--; iCount >= 0; iCount-- )
    if( m_arrResourceFont.GetAt( iCount )->m_nID == nID )
      break;

  return iCount;
}

void CEXResMng::InitResSet()
{
  ButtonResSet();
  EditResSet();
  SpinButtonResSet();
  DateTimeResSet();
  DropDownComboResSet();
  DropListComboResSet();
  HeaderCtrlResSet();
  ScrollBarResSet();
  IPAddressResSet();
  ListCtrlResSet();
  ListCtrlWndResSet();
  ProgressCtrlResSet();

  SliderCtrlResSet();
  StaticResSet();
  Dialog();
  MsgBox();
}

void CEXResMng::ButtonResSet()
{
  CEXButtonResSet *pResSetButton = new CEXButtonResSet;
  pResSetButton->m_arrImgId.Add(GetImg(IMG_PUSHBTN_BG));
  pResSetButton->m_nImg_DivideCnt = GetImgCount(IMG_PUSHBTN_BG);
  pResSetButton->m_font = GetFont(FONT_DARK_NORMAL);
  pResSetButton->m_crText = GetFontColor(FONT_DARK_NORMAL);
  pResSetButton->m_crBkColor = GetColor(COLOR_DARK);
  pResSetButton->m_nType = PUSH_BUTTON;
  RegResSet(RESSET_PUSHBTN_DARK_IMAGE_NORMAL, (CEXBaseResSet *)pResSetButton);

  pResSetButton = new CEXButtonResSet;
  pResSetButton->m_font = GetFont(FONT_DARK_SMALL);
  pResSetButton->m_crText = GetFontColor(FONT_DARK_SMALL);
  pResSetButton->m_crBkColor = GetColor(COLOR_BRIGHTNESS);
  pResSetButton->m_nType = NOIMAGE;
  RegResSet(RESSET_PUSHBTN_BRIGHTNESS_NOIMAGE_SMALL, 
    (CEXBaseResSet *)pResSetButton);

  pResSetButton = new CEXButtonResSet;
  pResSetButton->m_arrImgId.Add(GetImg(IMG_CHECKBTN_CHECK));
  pResSetButton->m_arrImgId.Add(GetImg(IMG_CHECKBTN_UNCHECK));
  pResSetButton->m_nImg_DivideCnt = GetImgCount(IMG_CHECKBTN_CHECK);
  pResSetButton->m_font = GetFont(FONT_DARK_NORMAL);
  pResSetButton->m_crText = GetFontColor(FONT_DARK_NORMAL);
  pResSetButton->m_crBkColor = GetColor(COLOR_DARK);
  pResSetButton->m_nType = CHECK_BUTTON;
  RegResSet(RESSET_CHECKBTN_DARK_IMAGE_NORMAL, (CEXBaseResSet *)pResSetButton);

  pResSetButton = new CEXButtonResSet;

  pResSetButton->m_font = GetFont(FONT_DARK_NORMAL);
  pResSetButton->m_crText = GetFontColor(FONT_DARK_NORMAL);
  pResSetButton->m_crBkColor = GetColor(COLOR_DARK);
  pResSetButton->m_nType = NOIMAGE;
  RegResSet(RESSET_CHECKBTN_DARK_NOIMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetButton);

  pResSetButton = new CEXButtonResSet;
  pResSetButton->m_arrImgId.Add(GetImg(IMG_RADIOBTN_CLICK));
  pResSetButton->m_arrImgId.Add(GetImg(IMG_RADIOBTN_UNCLICK));
  pResSetButton->m_nImg_DivideCnt = GetImgCount(IMG_RADIOBTN_CLICK);
  pResSetButton->m_font = GetFont(FONT_DARK_NORMAL);
  pResSetButton->m_crText = GetFontColor(FONT_DARK_NORMAL);
  pResSetButton->m_crBkColor = GetColor(COLOR_DARK);
  pResSetButton->m_nType = RADIO_BUTTON;
  RegResSet(RESSET_RADIOBTN_DARK_IMAGE_NORMAL, (CEXBaseResSet *)pResSetButton);

  pResSetButton = new CEXButtonResSet;
  pResSetButton->m_font = GetFont(FONT_DARK_NORMAL);
  pResSetButton->m_crText = GetFontColor(FONT_DARK_NORMAL);
  pResSetButton->m_crBkColor = GetColor(COLOR_DARK);
  pResSetButton->m_nType = NOIMAGE;
  RegResSet(RESSET_RADIOBTN_DARK_NOIMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetButton);
}

void CEXResMng::EditResSet()
{
  CEXEditResSet * pResSetEdit = new CEXEditResSet;  
  pResSetEdit->m_crSet = GetColorSet(COLORSET_BRIGHTNESS);
  pResSetEdit->m_font = GetFont(FONT_BRIGHTNESS_NORMAL);
  pResSetEdit->m_nImgId = GetImg(IMG_EDIT_SPIN_BG);
  pResSetEdit->m_nImg_DivideCnt = GetImgCount(IMG_EDIT_SPIN_BG);
  pResSetEdit->m_nType = EDIT_CTRL;
  RegResSet(RESSET_EDIT_BRIGHTNESS_SPIN_NORMAL, (CEXBaseResSet *)pResSetEdit);

  pResSetEdit = new CEXEditResSet;
  pResSetEdit->m_crSet = GetColorSet(COLORSET_BRIGHTNESS);
  pResSetEdit->m_font = GetFont(FONT_BRIGHTNESS_SMALL);
  pResSetEdit->m_nType = NOIMAGE;
  RegResSet(RESSET_EDIT_BRIGHTNESS_NOIMAGE_SMALL, (CEXBaseResSet *)pResSetEdit);
  

  pResSetEdit = new CEXEditResSet;
  pResSetEdit->m_crSet = GetColorSet(COLORSET_DARK);
  pResSetEdit->m_font = GetFont(FONT_DARK_NORMAL);
  pResSetEdit->m_nImgId = GetImg(IMG_EDIT_COMBO_BG);
  pResSetEdit->m_nImg_DivideCnt = GetImgCount(IMG_EDIT_COMBO_BG);
  pResSetEdit->m_nType = EDIT_CTRL;
  RegResSet(RESSET_EDIT_DARK_COMBOBG_NORMAL, (CEXBaseResSet *)pResSetEdit);

}
void CEXResMng::DateTimeResSet()
{
  CEXDateTimeCtrlResSet * pResSetDTimeCtrl = new CEXDateTimeCtrlResSet;
  pResSetDTimeCtrl->m_nImgId = GetImg(IMG_TEXTBOX_BG);
  pResSetDTimeCtrl->m_nImg_DivideCnt = GetImgCount(IMG_TEXTBOX_BG);
  pResSetDTimeCtrl->m_font = GetFont(FONT_DARK_NORMAL);
  pResSetDTimeCtrl->m_pSpinResSet = 
    (CEXSpinButtonCtrlResSet *)GetResSet(RESSET_SPINCTRL_DARK_IMAGE_NORMAL);
  pResSetDTimeCtrl->m_nType = DATETIME_CTRL;
  RegResSet(RESSET_DATETIME_DARK_IMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetDTimeCtrl);

  pResSetDTimeCtrl = new CEXDateTimeCtrlResSet;
  pResSetDTimeCtrl->m_font = GetFont(FONT_BRIGHTNESS_NORMAL);
  pResSetDTimeCtrl->m_nType = NOIMAGE;
  RegResSet(RESSET_DATETIME_BRIGHTNESS_NOIMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetDTimeCtrl);

}
void CEXResMng::DropDownComboResSet()
{  
  CEXDropdownComboBoxResSet *pResSetDropCombo = new CEXDropdownComboBoxResSet;
  pResSetDropCombo->m_arrImgId.Add(GetImg(IMG_COMBO_BG));
  pResSetDropCombo->m_nImg_DivideCnt = GetImgCount(IMG_COMBO_BG);
  pResSetDropCombo->m_arrImgId.Add(GetImg(IMG_COMBO_BTN));

  pResSetDropCombo->m_crNormal = GetColor(COLOR_DARK);
  pResSetDropCombo->m_crFocus = GetColor(COLOR_BASIC);
  pResSetDropCombo->m_font = GetFont(FONT_DARK_NORMAL);
  pResSetDropCombo->m_pEditResSet = 
    (CEXEditResSet *)GetResSet(RESSET_EDIT_DARK_COMBOBG_NORMAL);  //comboedit
  pResSetDropCombo->m_nType = DROPDOWN_COMBO_CTRL;
  RegResSet(RESSET_DOWNCOMBO_DARK_IMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetDropCombo);

  pResSetDropCombo = new CEXDropdownComboBoxResSet;
  pResSetDropCombo->m_arrImgId.Add(GetImg(IMG_COMBO_BG));
  pResSetDropCombo->m_nImg_DivideCnt = GetImgCount(IMG_COMBO_BG);
  pResSetDropCombo->m_arrImgId.Add(GetImg(IMG_COMBO_BTN));

  pResSetDropCombo->m_crNormal = GetColor(COLOR_BASIC);
  pResSetDropCombo->m_crFocus = GetColor(COLOR_BRIGHTNESS);
  pResSetDropCombo->m_font = GetFont(FONT_BRIGHTNESS_LARGE);
  pResSetDropCombo->m_pEditResSet = 
    (CEXEditResSet *)GetResSet(RESSET_EDIT_DARK_COMBOBG_NORMAL);
  pResSetDropCombo->m_nType = DROPDOWN_COMBO_CTRL;
  RegResSet(RESSET_DOWNCOMBO_BRIGHTNESS_IMAGE_LARGE, 
            (CEXBaseResSet *)pResSetDropCombo);
}
void CEXResMng::DropListComboResSet()
{
  CEXDropListComboBoxResSet *pResSetListCombo = new CEXDropListComboBoxResSet;
  pResSetListCombo->m_arrImgId.Add(GetImg(IMG_COMBO_BG));
  pResSetListCombo->m_nImg_DivideCnt = GetImgCount(IMG_COMBO_BG);
  pResSetListCombo->m_arrImgId.Add(GetImg(IMG_COMBO_BTN));

  pResSetListCombo->m_crNormal = GetColor(COLOR_DARK);
  pResSetListCombo->m_crFocus = GetColor(COLOR_BASIC);
  pResSetListCombo->m_font = GetFont(FONT_DARK_NORMAL);
  pResSetListCombo->m_nType = LISTDOWN_COMBO_CTRL;
  RegResSet(RESSET_LISTCOMBO_DARK_IMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetListCombo);

  pResSetListCombo = new CEXDropListComboBoxResSet;
  pResSetListCombo->m_arrImgId.Add(GetImg(IMG_COMBO_BG));
  pResSetListCombo->m_nImg_DivideCnt = GetImgCount(IMG_COMBO_BG);
  pResSetListCombo->m_arrImgId.Add(GetImg(IMG_COMBO_BTN));

  pResSetListCombo->m_crNormal = GetColor(COLOR_BRIGHTNESS);
  pResSetListCombo->m_crFocus = GetColor(COLOR_BASIC);
  pResSetListCombo->m_font = GetFont(FONT_BRIGHTNESS_NORMAL);
  pResSetListCombo->m_nType = LISTDOWN_COMBO_CTRL;
  RegResSet(RESSET_LISTCOMBO_BRIGHTNESS_IMAGE_SMALL, 
            (CEXBaseResSet *)pResSetListCombo);
}
void CEXResMng::HeaderCtrlResSet() 
{
  CEXHeaderCtrlResSet * pResSetHeaderCtrl = new CEXHeaderCtrlResSet;
  pResSetHeaderCtrl->m_nImgId = GetImg(IMG_HEADER_BG);
  pResSetHeaderCtrl->m_font = GetFont(FONT_DARK_NORMAL);
  pResSetHeaderCtrl->m_crBkColor = GetColor(COLOR_DARK);
  pResSetHeaderCtrl->m_crText = GetColor(FONT_DARK_NORMAL);
  pResSetHeaderCtrl->m_nType = HEADER_CTRL;
  RegResSet(RESSET_HEADERCTRL_DARK_IMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetHeaderCtrl);

  pResSetHeaderCtrl = new CEXHeaderCtrlResSet;
  pResSetHeaderCtrl->m_font = GetFont(FONT_BRIGHTNESS_SMALL);
  pResSetHeaderCtrl->m_crBkColor = GetColor(COLOR_BRIGHTNESS);
  pResSetHeaderCtrl->m_crText = GetColor(FONT_BRIGHTNESS_SMALL);
  pResSetHeaderCtrl->m_nType = NOIMAGE;
  RegResSet(RESSET_HEADERCTRL_BRIGHTNESS_NOIMAGE_SMALL, 
            (CEXBaseResSet *)pResSetHeaderCtrl);
}
void CEXResMng::IPAddressResSet()
{
  CEXIPAddressCtrlResSet * pResSetIPAddress = new CEXIPAddressCtrlResSet;
  pResSetIPAddress->m_font = GetFont(FONT_DARK_NORMAL);
  pResSetIPAddress->m_arrImgId.Add(GetImg(IMG_TEXTBOX_BG));
  pResSetIPAddress->m_arrImgId.Add(GetImg(IMG_IP_TEXTBOX_BG));
  pResSetIPAddress->m_nImg_DivideCnt = GetImgCount(IMG_TEXTBOX_BG);
  pResSetIPAddress->m_nType = IPADDRESS_CTRL;
  RegResSet(RESSET_IPADDRESS_DARK_IMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetIPAddress);

  pResSetIPAddress = new CEXIPAddressCtrlResSet;
  pResSetIPAddress->m_font = GetFont(FONT_BRIGHTNESS_NORMAL);
  pResSetIPAddress->m_nType = NOIMAGE;
  RegResSet(RESSET_IPADDRESS_BRIGHTNESS_NOIMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetIPAddress);
}
void CEXResMng::ListCtrlResSet()
{
  CEXListCtrlResSet * pResSetListCtrl = new CEXListCtrlResSet;
  pResSetListCtrl->m_font = GetFont(FONT_DARK_NORMAL);
  pResSetListCtrl->m_crEven = GetColor(COLOR_BASIC);
  pResSetListCtrl->m_crOdd = GetColor(COLOR_DARK);
  pResSetListCtrl->m_crText = GetColor(FONT_DARK_NORMAL);
  pResSetListCtrl->m_headerCtrlResSet = 
    (CEXHeaderCtrlResSet *)GetResSet(RESSET_HEADERCTRL_DARK_IMAGE_NORMAL);
  RegResSet(RESSET_LISTCTRL_DARK_IMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetListCtrl);

  pResSetListCtrl = new CEXListCtrlResSet;
  pResSetListCtrl->m_font = GetFont(FONT_BRIGHTNESS_LARGE);
  pResSetListCtrl->m_crEven = GetColor(COLOR_BASIC);
  pResSetListCtrl->m_crOdd = GetColor(COLOR_BRIGHTNESS);
  pResSetListCtrl->m_crText = GetColor(FONT_BRIGHTNESS_LARGE);
  pResSetListCtrl->m_headerCtrlResSet = 
   (CEXHeaderCtrlResSet *)GetResSet(RESSET_HEADERCTRL_BRIGHTNESS_NOIMAGE_SMALL);
  RegResSet(RESSET_LISTCTRL_BRIGHTNESS_NOIMAGE_LARGE, 
            (CEXBaseResSet *)pResSetListCtrl);
}
void CEXResMng::ListCtrlWndResSet()
{
  CEXListCtrlWndResSet *pResSetListCtrlWnd = new CEXListCtrlWndResSet;
  pResSetListCtrlWnd->m_listCtrlResSet = 
    (CEXListCtrlResSet *)GetResSet(RESSET_LISTCTRL_DARK_IMAGE_NORMAL);
  pResSetListCtrlWnd->m_VscrollResSet = 
    (CEXScrollBarResSet *)GetResSet(RESSET_VSCROLLBAR_IMAGE_LARGE);
  pResSetListCtrlWnd->m_HscrollResSet = 
    (CEXScrollBarResSet *)GetResSet(RESSET_HSCROLLBAR_IMAGE_NORMAL);
  RegResSet(RESSET_LISTCTRLWND_DARK_IMAGE_NORMAL,
            (CEXBaseResSet *)pResSetListCtrlWnd);

  pResSetListCtrlWnd = new CEXListCtrlWndResSet;
  pResSetListCtrlWnd->m_listCtrlResSet = 
    (CEXListCtrlResSet *)GetResSet(RESSET_LISTCTRL_BRIGHTNESS_NOIMAGE_LARGE);
  pResSetListCtrlWnd->m_VscrollResSet = 
    (CEXScrollBarResSet *)GetResSet(RESSET_SCROLLBAR_DARK_NOIMAGE_NORMAL);
  pResSetListCtrlWnd->m_HscrollResSet = 
    (CEXScrollBarResSet *)GetResSet(RESSET_SCROLLBAR_DARK_NOIMAGE_NORMAL);
  RegResSet(RESSET_LISTCTRLWND_BRIGHTNESS_NOIMAGE_NORMAL,
            (CEXBaseResSet *)pResSetListCtrlWnd);

}
void CEXResMng::ProgressCtrlResSet()
{
  CEXProgressCtrlResSet *pResSetProgressCtrl = new CEXProgressCtrlResSet;
  pResSetProgressCtrl->m_arrImgId.Add(GetImg(IMG_PROGRESS_BG));
  
  pResSetProgressCtrl->m_arrImgId.Add(GetImg(IMG_PROGRESS_BAR));
  pResSetProgressCtrl->m_nImg_DivideCnt = GetImgCount(IMG_PROGRESS_BAR);
  pResSetProgressCtrl->m_nType = PROGRESS_CTRL;
  RegResSet(RESSET_PROGRESSCTRL_DARK_IMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetProgressCtrl);

  pResSetProgressCtrl = new CEXProgressCtrlResSet;
  pResSetProgressCtrl->m_nType = NOIMAGE;
  RegResSet(RESSET_PROGRESSCTRL_DARK_NOIMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetProgressCtrl);
}
void CEXResMng::ScrollBarResSet()
{
  CEXScrollBarResSet *pResSetScrollBar = new CEXScrollBarResSet;
  pResSetScrollBar->m_arrImgId.Add(GetImg(IMG_HSCROLL_LEFT));
  pResSetScrollBar->m_arr_nImg_DivideCnt.Add(GetImgCount(IMG_HSCROLL_LEFT));
  pResSetScrollBar->m_arrImgId.Add(GetImg(IMG_HSCROLL_RIGHT));
  pResSetScrollBar->m_arr_nImg_DivideCnt.Add(GetImgCount(IMG_HSCROLL_RIGHT));
  pResSetScrollBar->m_arrImgId.Add(GetImg(IMG_HSCROLL_BG));
  pResSetScrollBar->m_arr_nImg_DivideCnt.Add(GetImgCount(IMG_HSCROLL_BG));
  pResSetScrollBar->m_arrImgId.Add(GetImg(IMG_HSCROLL_THUMB));
  pResSetScrollBar->m_arr_nImg_DivideCnt.Add(GetImgCount(IMG_HSCROLL_THUMB));
  pResSetScrollBar->m_arrImgId.Add(GetImg(IMG_HSCROLL_THUMB_BG));
  pResSetScrollBar->m_arr_nImg_DivideCnt.Add(GetImgCount(IMG_HSCROLL_THUMB_BG));
  pResSetScrollBar->m_arrImgId.Add(GetImg(IMG_HSCROLL_THUMB_ARROW));
  pResSetScrollBar->m_arr_nImg_DivideCnt.Add(
    GetImgCount(IMG_HSCROLL_THUMB_ARROW));
  pResSetScrollBar->m_nType = SCROLLBAR_CTRL;
  RegResSet(RESSET_HSCROLLBAR_IMAGE_NORMAL, (CEXBaseResSet *)pResSetScrollBar);

  pResSetScrollBar = new CEXScrollBarResSet;
  pResSetScrollBar->m_arrImgId.Add(GetImg(IMG_VSCROLL_LEFT));
  pResSetScrollBar->m_arr_nImg_DivideCnt.Add(GetImgCount(IMG_VSCROLL_LEFT));
  pResSetScrollBar->m_arrImgId.Add(GetImg(IMG_VSCROLL_RIGHT));
  pResSetScrollBar->m_arr_nImg_DivideCnt.Add(GetImgCount(IMG_VSCROLL_RIGHT));
  pResSetScrollBar->m_arrImgId.Add(GetImg(IMG_VSCROLL_BG));
  pResSetScrollBar->m_arr_nImg_DivideCnt.Add(GetImgCount(IMG_VSCROLL_BG));
  pResSetScrollBar->m_arrImgId.Add(GetImg(IMG_VSCROLL_THUMB));
  pResSetScrollBar->m_arr_nImg_DivideCnt.Add(GetImgCount(IMG_VSCROLL_THUMB));
  pResSetScrollBar->m_arrImgId.Add(GetImg(IMG_VSCROLL_THUMB_BG));
  pResSetScrollBar->m_arr_nImg_DivideCnt.Add(GetImgCount(IMG_VSCROLL_THUMB_BG));
  pResSetScrollBar->m_arrImgId.Add(GetImg(IMG_VSCROLL_THUMB_ARROW));
  pResSetScrollBar->m_arr_nImg_DivideCnt.Add(
    GetImgCount(IMG_VSCROLL_THUMB_ARROW));
  pResSetScrollBar->m_nType = SCROLLBAR_CTRL;
  RegResSet(RESSET_VSCROLLBAR_IMAGE_LARGE, (CEXBaseResSet *)pResSetScrollBar);
}
void CEXResMng::SliderCtrlResSet()
{
  CEXSliderCtrlResSet* pResSetSliderCtrl = new CEXSliderCtrlResSet;
  pResSetSliderCtrl->m_arrImgId.Add(GetImg(IMG_SLIDER_CHANNEL_H));
  pResSetSliderCtrl->m_arrImgId.Add(GetImg(IMG_SLIDER_THUMB_H));
  pResSetSliderCtrl->m_nImg_DivideCnt = GetImgCount(IMG_SLIDER_THUMB_H);
  pResSetSliderCtrl->m_crBkColor = GetColor(COLOR_DARK);
  pResSetSliderCtrl->m_nType = SLIDER_CTRL;
  RegResSet(RESSET_SLIDERCTRL_DARK_IMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetSliderCtrl);

  pResSetSliderCtrl = new CEXSliderCtrlResSet;
  pResSetSliderCtrl->m_crBkColor = GetColor(COLOR_BRIGHTNESS);
  pResSetSliderCtrl->m_nType = NOIMAGE;
  RegResSet(RESSET_SLIDERCTRL_BRIGHTNESS_NOIMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetSliderCtrl);
}
void CEXResMng::SpinButtonResSet()
{
  CEXSpinButtonCtrlResSet *pResSetSpinCtrl = new CEXSpinButtonCtrlResSet;
  pResSetSpinCtrl->m_arrImgId.Add(GetImg(IMG_SPIN_VERT_BG));
  pResSetSpinCtrl->m_arrImgId.Add(GetImg(IMG_SPIN_VERT_UP));
  pResSetSpinCtrl->m_arrImgId.Add(GetImg(IMG_SPIN_VERT_DOWN));
  pResSetSpinCtrl->m_nImg_DivideCnt = GetImgCount(IMG_SPIN_VERT_BG);
  pResSetSpinCtrl->m_crBkColor = GetColor(COLOR_DARK);
  pResSetSpinCtrl->m_nType = SPIN_CTRL;
  RegResSet(RESSET_SPINCTRL_DARK_IMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetSpinCtrl);

  pResSetSpinCtrl = new CEXSpinButtonCtrlResSet;
  pResSetSpinCtrl->m_nType = NOIMAGE;
  RegResSet(RESSET_SPINCTRL_DARK_NOIMAGE_LARGE, 
            (CEXBaseResSet *)pResSetSpinCtrl);
}
void CEXResMng::StaticResSet()
{
  CEXStaticResSet *pResSetStatic = new CEXStaticResSet;
  pResSetStatic->m_nImgId = GetImg(IMG_STATIC_BG);
  pResSetStatic->m_font = GetFont(FONT_DARK_NORMAL);
  pResSetStatic->m_crBkColor = GetColor(COLOR_DARK);
  pResSetStatic->m_crText = GetColor(FONT_DARK_NORMAL);
  pResSetStatic->m_nType = STATIC_CTRL;
  RegResSet(RESSET_STATIC_DARK_IMAGE_NORMAL, (CEXBaseResSet *)pResSetStatic);

  pResSetStatic = new CEXStaticResSet;
  pResSetStatic->m_font = GetFont(FONT_BRIGHTNESS_NORMAL);
  pResSetStatic->m_crBkColor = GetColor(COLOR_BRIGHTNESS);
  pResSetStatic->m_crText = GetColor(FONT_BRIGHTNESS_NORMAL);
  pResSetStatic->m_nType = NOIMAGE;
  RegResSet(RESSET_STATIC_BRIGHTNESS_NOIMAGE_NORMAL, 
            (CEXBaseResSet *)pResSetStatic);

  pResSetStatic = new CEXStaticResSet;
  pResSetStatic->m_font = GetFont(FONT_DARK_SMALL);
  pResSetStatic->m_crBkColor = GetColor(COLOR_DARK_DIALOG);
  pResSetStatic->m_crText = GetColor(FONT_DARK_SMALL);
  pResSetStatic->m_nType = NOIMAGE;
  RegResSet(RESSET_STATIC_DARK_NOIMAGE_SMALL_DIALOG, 
    (CEXBaseResSet *)pResSetStatic);
}
void CEXResMng::Dialog()
{
  CEXDialogResSet * pResSetDlg = new CEXDialogResSet;
  pResSetDlg->m_arrImgId.Add(GetImg(IMG_DIALOG_TOP));
  pResSetDlg->m_arrImgId.Add(GetImg(IMG_DIALOG_BOTTOM));
  pResSetDlg->m_arrImgId.Add(GetImg(IMG_DIALOG_LEFT));
  pResSetDlg->m_arrImgId.Add(GetImg(IMG_DIALOG_RIGHT));
  pResSetDlg->m_arrImgId.Add(GetImg(IMG_DIALOG_LEFT_TOP));
  pResSetDlg->m_arrImgId.Add(GetImg(IMG_DIALOG_LEFT_BOTTOM));
  pResSetDlg->m_arrImgId.Add(GetImg(IMG_DIALOG_RIGHT_TOP));
  pResSetDlg->m_arrImgId.Add(GetImg(IMG_DIALOG_RIGHT_BOTTOM));

  pResSetDlg->m_font = GetFont(FONT_DARK_SMALL);
  pResSetDlg->m_crBkColor = GetColor(COLOR_DARK_DIALOG);
  pResSetDlg->m_crText = GetColor(FONT_DARK_SMALL);
  pResSetDlg->m_nType = DIALOG_CTRL;
  RegResSet(RESSET_DIALOG_DARK_IMAGE_SMALL, (CEXBaseResSet *)pResSetDlg);

  pResSetDlg = new CEXDialogResSet;
  pResSetDlg->m_font = GetFont(FONT_DARK_SMALL);
  pResSetDlg->m_crBkColor = GetColor(COLOR_DARK_DIALOG);
  pResSetDlg->m_crText = GetColor(FONT_DARK_SMALL);
  pResSetDlg->m_nType = NOIMAGE;
  RegResSet(RESSET_DIALOG_DARK_NOIMAGE_SMALL, (CEXBaseResSet *)pResSetDlg);
  
}
void CEXResMng::MsgBox()
{
  CEXMsgBoxResSet * pResSetMsgBox = new CEXMsgBoxResSet;
  pResSetMsgBox->m_nImgId = GetImg(IMG_MSGBOX_BG);
  pResSetMsgBox->m_nImg_DivideCnt = GetImgCount(IMG_MSGBOX_BG);
  pResSetMsgBox->m_DialogResSet = 
    (CEXDialogResSet *)GetResSet(RESSET_DIALOG_DARK_IMAGE_SMALL);
  pResSetMsgBox->m_nType = MSGBOX_CTRL;
  RegResSet(RESSET_MSGBOX_DARK_IMAGE_SMALL, (CEXBaseResSet *)pResSetMsgBox);

  pResSetMsgBox = new CEXMsgBoxResSet;
  pResSetMsgBox->m_DialogResSet = 
    (CEXDialogResSet *)GetResSet(RESSET_DIALOG_DARK_NOIMAGE_SMALL);
  pResSetMsgBox->m_nType = NOIMAGE;
  RegResSet(RESSET_MSGBOX_DARK_NOIMAGE_SMALL, (CEXBaseResSet *)pResSetMsgBox);
}

void CEXResMng::RegResSet(UINT nId, CEXBaseResSet *pResSet)
{
  RESOURCE_SET* pResourceSet = new RESOURCE_SET;
  pResourceSet->m_nId = nId;
  pResourceSet->m_pResSet = pResSet;

  m_arrResSet.Add(pResourceSet);
}

 CEXBaseResSet* CEXResMng::GetResSet(UINT nId)
{
  INT_PTR nIndex = GetResSetIndex(nId);
  if( nIndex < 0 || nIndex >= m_arrResSet.GetSize() )
    return NULL;

  return m_arrResSet.GetAt( nIndex )->m_pResSet;
}

 INT_PTR CEXResMng::GetResSetIndex(UINT nResSetID)
 {
   INT_PTR iCount = m_arrResSet.GetSize();
   for( INT_PTR iIndex = 0; iIndex < iCount; iIndex++ )
   {
     if( m_arrResSet.GetAt( iIndex ) == NULL )
       continue;

     if( m_arrResSet.GetAt( iIndex )->m_nId == nResSetID )
       return iIndex;
   }

   return -1;
 }